
proc MidVector { vector1 vector2 } {
	set a1 [lindex $vector1 0]
	set a2 [lindex $vector1 1]
	set a3 [lindex $vector1 2]

	set b1 [lindex $vector2 0]
	set b2 [lindex $vector2 1]
	set b3 [lindex $vector2 2]

	set c1 [expr {0.5*($a1 + $b1)} ]
	set c2 [expr {0.5*($a2 + $b2)} ]
	set c3 [expr {0.5*($a3 + $b3)} ]

	return [list $c1 $c2 $c3]
}

##
set state [ hm_commandfilestate 0 ]
hm_blockmessages 1
##
hm_holedetectionend
hm_holedetectioninit
*createmarkpanel solids 1 "Please select the solids"
set maxd [ hm_getfloat "max diameter"]
hm_holedetectionsetentities solids 1
hm_holedetectionsettubeparams tube_shape=2 tube_type=0  max_planar_dim=$maxd
hm_holedetectionfindholes 4
set n [hm_holedetectiongetnumberofholes]
if { $n > 0 } {
	puts "Number of holes = $n"
	for {set i 0} {$i < $n} {incr i} {
		set center_top [hm_holedetectiongetholedetailsdata $i center_top]
		set center_bottom [hm_holedetectiongetholedetailsdata $i center_bottom]
		set center [eval MidVector $center_top $center_bottom ]
		eval *createpoint $center 0
	}
} else {
	puts  "Holes not detected."
}
hm_holedetectionend

##
hm_blockmessages 0
hm_commandfilestate $state
##

*clearmark solids 1
